<template>
  <!-- 用户-用户列表 -->
  <div>
    <Card :bordered="false" dis-hover class="ivu-mt" :padding="0">
      <div class="padding-add">
        <!-- 筛选条件 -->
        <Form
            ref="userFrom"
            :model="userFrom"
            :label-width="labelWidth"
            :label-position="labelPosition"
            @submit.native.prevent
        >
          <Row :gutter="24">
            <Col span="18">
              <Row>
                <Col span="24">
                  <Row>
                    <Col>
                      <FormItem label="用户搜索：" label-for="nickname">
                        <Input
                            v-model="userFrom.nickname"
                            placeholder="请输入"
                            element-id="nickname"
                            clearable
                            class="input-add"
                        >
                          <Select
                              v-model="field_key"
                              slot="prepend"
                              style="width: 80px"
                          >
                            <Option value="all">全部</Option>
                            <Option value="uid">UID</Option>
                            <Option value="phone">手机号</Option>
                            <Option value="username">用户昵称</Option>
                            <Option value="email">邮箱</Option>
                          </Select>
                        </Input>
                      </FormItem>
                    </Col>
                  </Row>
                </Col>
              </Row>
            </Col>
            <template v-if="collapse">
              <Col span="18">
                <Row>
                  <Col class="dateMedia">
                    <FormItem label="访问时间：" label-for="user_time">
                      <DatePicker
                          :editable="false"
                          @on-change="onchangeTime"
                          :value="timeVal"
                          format="yyyy/MM/dd"
                          type="daterange"
                          placement="bottom-start"
                          placeholder="自定义时间"
                          :options="options"
                          class="input-add"
                      ></DatePicker>
                    </FormItem>
                  </Col>
                  <Col>
                    <FormItem label="下单次数：" label-for="pay_count">
                      <Select
                          v-model="userFrom.pay_count"
                          placeholder="请选择"
                          element-id="pay_count"
                          clearable
                          class="input-add"
						            @on-change="userSearchs"
                      >
                        <!--                        <Option value="">全部</Option>-->
                        <Option value="-1">0次</Option>
                        <Option value="0">1次以上</Option>
                        <Option value="1">2次以上</Option>
                        <Option value="2">3次以上</Option>
                        <Option value="3">4次以上</Option>
                        <Option value="4">5次以上</Option>
                      </Select>
                    </FormItem>
                  </Col>
                </Row>
              </Col>
            </template>
            <Col span="6" class="ivu-text-right userFrom">
              <FormItem>
                <Button
                    type="primary"
                    label="default"
                    class="mr15"
                    @click="userSearchs"
                >搜索</Button
                >
                <Button class="ResetSearch" @click="reset('userFrom')"
                >重置</Button
                >
                <a v-font="14" class="ivu-ml-8" @click="collapse = !collapse">
                  <template v-if="!collapse">
                    展开 <Icon type="ios-arrow-down" />
                  </template>
                  <template v-else>
                    收起 <Icon type="ios-arrow-up" />
                  </template>
                </a>
              </FormItem>
            </Col>
          </Row>
        </Form>
      </div>
    </Card>
    <Card :bordered="false" dis-hover class="ivu-mt listbox">
      <div class="new_tab">
        <!-- Tab栏切换 -->
        <Tabs v-model="headeType" @on-click="onClickTab">
          <TabPane
              :label="item.name"
              :name="item.type"
              v-for="(item, index) in headeNum"
              :key="index"
          />
        </Tabs>
      </div>
      <Row type="flex" justify="space-between">
        <!-- 相关操作 -->
        <Col span="24">

        </Col>
      </Row>
      <!-- 用户列表表格 -->
      <vxe-table
          ref="xTable"
          height="600"
          class="mt25"
          :loading="loading"
          row-id="uid"
          :expand-config="{accordion: true}"
          :checkbox-config="{reserve: true}"
          :data="userLists">
        <vxe-column type="expand" width="35">
          <template #content="{ row }">
            <div class="tdinfo">
              <Row class="expand-row">
                <Col span="6">
                  <span class="expand-key">近次访问：</span>
                  <span class="expand-value">{{row.last_time  | formatDate}}</span>
                </Col>
                <Col span="6">
                  <span class="expand-key">身份证号：</span>
                  <span class="expand-value">{{row.card_id}}</span>
                </Col>
                <Col span="6">
                  <span class="expand-key">真实姓名：</span>
                  <span class="expand-value">{{row.real_name}}</span>
                </Col>
              </Row>
              <Row class="expand-row">
                <Col span="6">
                  <span class="expand-key">地址：</span>
                  <span class="expand-value">{{row.addres}}</span>
                </Col>
              </Row>
              <Row class="expand-row">
                <Col span="6">
                  <span class="expand-key">备注：</span>
                  <span class="expand-value">{{row.remark}}</span>
                </Col>
              </Row>
            </div>
          </template>
        </vxe-column>
        <vxe-column field="id" title="UID" width="60"></vxe-column>
        <vxe-column field="avatars" title="头像" width="50">
          <template v-slot="{ row }">
            <viewer>
              <div class="tabBox_img">
                <img v-lazy="row.avatar" @click="handleView(row.avatar)" />
              </div>
            </viewer>
          </template>
        </vxe-column>
        <vxe-column field="username" title="昵称" min-width="150">
          <template v-slot="{ row }">
            <div class="acea-row">
              <div v-if="row.status == 2" style="color:#ed4014;">{{row.username}} (已关闭)</div>
              <div v-else v-text="row.username"></div>
            </div>
          </template>
        </vxe-column>
        <vxe-column field="phone" title="手机号" min-width="110"></vxe-column>
        <vxe-column field="email" title="邮箱" min-width="110"></vxe-column>
        <vxe-column field="company" title="公司名称" min-width="110"></vxe-column>
        <vxe-column field="tax_id" title="税号" min-width="110"></vxe-column>
        <vxe-column field="status" title="状态" min-width="110">
          <template v-slot="{ row }">
            <div class="acea-row">
              <p  v-if="row.status == 0">待审核</p>
              <p  v-else-if="row.status == 3">未提交审核</p>
              <p  v-else-if="row.status == 4">审核失败</p>
              <i-switch v-else v-model="row.status"  @on-change="onchangeIsShow(row)" size="large" :true-value="1" :false-value="2">
                <span slot="open">开启</span>
                <span slot="close">关闭</span>
              </i-switch>
            </div>
          </template>
        </vxe-column>
		<vxe-column field="is_staff" title="是否员工" min-width="110">
		  <template v-slot="{ row }">
		    <div class="acea-row">
		      <i-switch v-model="row.is_staff"  @on-change="onchangeIsStaff(row)" size="large" :true-value="1" :false-value="0">
		        <span slot="open">是</span>
		        <span slot="close">否</span>
		      </i-switch>
		    </div>
		  </template>
		</vxe-column>
        <vxe-column field="action" title="操作" align="center" width="180" fixed="right">
          <template v-slot="{ row }">
			  <!-- <a @click="editUser(row, '1')">编辑</a>
			  <Divider type="vertical" /> -->
            <a @click="changeMenu(row, '1')">详情</a>
            <Divider type="vertical" v-if=" row.status == 0"/>
            <a @click="userverify(row)" v-if="row.status == 0">审核</a>
          </template>
        </vxe-column>
      </vxe-table>
      <div class="acea-row row-right page">
        <Page
            :total="total"
            :current="userFrom.page"
            show-elevator
            show-total
            @on-change="pageChange"
            :page-size="userFrom.limit"
        />
      </div>
    </Card>
    <!-- 会员详情-->
    <user-details ref="userDetails" :group-list="groupList"></user-details>

    <!-- 审核 -->
    <Modal title="审核" v-model="checkmodal" :mask-closable="false">
      <Form :model="formCheckItem" :label-width="80">
        <FormItem label="审核状态：">
          <RadioGroup v-model="formCheckItem.type">
            <Radio label="1">通过</Radio>
            <Radio label="4">拒绝</Radio>
          </RadioGroup>
        </FormItem>
        <FormItem label="拒绝原因：" v-if="formCheckItem.type == 4">
          <Input v-model="formCheckItem.message" :maxlength="100" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入拒绝原因"></Input>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button @click="cancel">取消</Button>
        <Button type="primary"  @click="ok">提交</Button>

      </div>
    </Modal>
	
	<!-- 编辑 -->
	<Modal title="编辑" v-model="editUsermodal" :mask-closable="false">
	  <Form :model="formData" :label-width="80">
	    <FormItem label="是否员工：">
	      <RadioGroup v-model="formData.is_staff">
	        <Radio label="0">否</Radio>
	        <Radio label="1">是</Radio>
	      </RadioGroup>
	    </FormItem>
		
	    <FormItem label="账号：">
	      <Input v-model="formData.username" disabled></Input>
	    </FormItem>
		<FormItem label="邮箱：">
		  <Input v-model="formData.email" disabled></Input>
		</FormItem>
		<FormItem label="公司：">
		  <Input v-model="formData.company" disabled></Input>
		</FormItem>
		<FormItem label="密码：">
		  <Input v-model="formData.password"></Input>
		</FormItem>
	  </Form>
	  <div slot="footer">
	    <Button @click="cancel">取消</Button>
	    <Button type="primary"  @click="ok">提交</Button>
	
	  </div>
	</Modal>
	
    <look-image ref="lookImage" :imageUrl="imageUrl"></look-image>

  </div>
</template>

<script>
import { formatDate } from '@/utils/validate';
import userLabel from "../../../components/userLabel";
import labelList from "@/components/labelList";
import { mapState } from "vuex";
import expandRow from "./tableExpand.vue";
import {
  storeExtractVerifyApi
} from "@/api/store";
import {
  userList,
  getUserData,
  isShowApi,
  isStaffApi,
  editOtherApi,
  giveLevelApi,
  userSetGroup,
  userGroupApi,
  levelListApi,
  userSetLabelApi,
  userLabelApi,
  userSynchro,
  getUserSaveForm,
  giveLevelTimeApi,
  extendInfo,
  batchProcess
} from "@/api/user";
import { agentSpreadApi } from "@/api/agent";
import editFrom from "../../../components/from/from";
import sendFrom from "@/components/sendCoupons/index";
import userDetails from "./handle/userDetails";
import newsCategory from "@/components/newsCategory/index";
import city from "@/utils/city";
import customerInfo from "@/components/customerInfo";
import lookImage from "@/components/fromBuild/lookImage.vue";
export default {
  name: "user_list",
  filters: {
    formatDate (time) {
      if (time !== 0) {
        let date = new Date(time);
        return formatDate(date, 'yyyy-MM-dd hh:mm');
      }
    }
  },
  components: {
    lookImage,
    expandRow,
    editFrom,
    sendFrom,
    userDetails,
    newsCategory,
    customerInfo,
    userLabel,
    labelList,
  },
  data() {
    return {
      imageUrl:'',
      checkmodal:false,
	  editUsermodal:false,
      formCheckItem:{
        type:"1",
        message:""
      },
      dataLabel: [],
      labelListShow: false,
      labelShow: false,
      customerShow: false,
      promoterShow: false,
      labelActive: {
        uid: 0,
      },
      formInline: {
        uid: 0,
        spread_uid: 0,
        image: "",
      },
	  formData:{
		  username:"",
		  email:"",
		  phone:"",
		  company:"",
		  is_staff:0,
		  password:"",
	  },
      options: {
        shortcuts: [
          {
            text: "今天",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  new Date(
                      new Date().getFullYear(),
                      new Date().getMonth(),
                      new Date().getDate()
                  )
              );
              return [start, end];
            },
          },
          {
            text: "昨天",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  start.setTime(
                      new Date(
                          new Date().getFullYear(),
                          new Date().getMonth(),
                          new Date().getDate() - 1
                      )
                  )
              );
              end.setTime(
                  end.setTime(
                      new Date(
                          new Date().getFullYear(),
                          new Date().getMonth(),
                          new Date().getDate() - 1
                      )
                  )
              );
              return [start, end];
            },
          },
          {
            text: "最近7天",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  start.setTime(
                      new Date(
                          new Date().getFullYear(),
                          new Date().getMonth(),
                          new Date().getDate() - 6
                      )
                  )
              );
              return [start, end];
            },
          },
          {
            text: "最近30天",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  start.setTime(
                      new Date(
                          new Date().getFullYear(),
                          new Date().getMonth(),
                          new Date().getDate() - 29
                      )
                  )
              );
              return [start, end];
            },
          },
		  {
		    text: "上月",
		    value() {
		      const end = new Date();
		      const start = new Date();
		  	const day = new Date(start.getFullYear(), start.getMonth(), 0).getDate();
		      start.setTime(
		        start.setTime(
		          new Date(new Date().getFullYear(), new Date().getMonth()-1, 1)
		        )
		      );
		  	end.setTime(
		  	  end.setTime(
		  	    new Date(new Date().getFullYear(), new Date().getMonth()-1, day)
		  	  )
		  	);
		      return [start, end];
		    },
		  },
          {
            text: "本月",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  start.setTime(
                      new Date(new Date().getFullYear(), new Date().getMonth(), 1)
                  )
              );
              return [start, end];
            },
          },
          {
            text: "本年",
            value() {
              const end = new Date();
              const start = new Date();
              start.setTime(
                  start.setTime(new Date(new Date().getFullYear(), 0, 1))
              );
              return [start, end];
            },
          },
        ],
      },
      collapse: false,
      headeType: "-1",
      headeNum: [
        { type: "-1", name: "全部" }
      ],
      address: [],
      addresData: city,
      isShowSend: true,
      modal13: false,
      maxCols: 4,
      scrollerHeight: "600",
      contentTop: "130",
      contentWidth: "98%",
      grid2: {
        xl: 18,
        lg: 16,
        md: 12,
        sm: 24,
        xs: 24,
      },
      loading: false,
      total: 0,
      userFrom: {
        status: "",
        sex: "",
        is_promoter: "",
        country: "",
        isMember: "",
        pay_count: "",
        user_time_type: "",
        user_time: "",
        nickname: "",
        province: "",
        page: 1,
        limit: 15,
        field_key: "",
      },
      field_key: "",
      level: "",
      group_id: "",
      label_id: "",
      user_time_type: "",
      pay_count: "",
      userLists: [],
      FromData: null,
      selectionList: [],
      user_ids: "",
      selectedData: [],
      timeVal: [],
      array_ids: [],
      groupList: [],
      levelList: [],
      labelFrom: {
        page: 1,
        limit: "",
      },
      labelLists: [],
      display: "none",
      checkBox: false,
      selectionCopy: [],
      isCheckBox: false,
      isAll: 0,
      userId: 0,
      checkUidList:[],
      batchModal: false,
      menuActive: 1,
      batchLabel: [],
      batchData: {
        group_id: 0,
        label_id: [],
        level_id: 0,
        money_status: 0,
        money: 0,
        integration_status: 0,
        integration: 0,
        days_status: 1,
        day: 0,
        spread_uid: '',
      },
      spread_name: ''
    };
  },
  watch: {
    selectionList(value) {
      let arr = value.map((item) => item.uid);
      this.array_ids = arr;
      this.user_ids = arr.join();
    },
    userLists: {
      deep: true,
      handler(value) {
        value.forEach((item) => {
          this.selectionList.forEach((itm) => {
            if (itm.uid === item.uid) {
              item.checkBox = true;
            }
          });
        });
        const arr = this.userLists.filter((item) => item.checkBox);
        if (this.userLists.length) {
          this.checkBox = this.userLists.length === arr.length;
        } else {
          this.checkBox = false;
        }
      },
    },
  },
  computed: {
    ...mapState("admin/layout", ["isMobile"]),
    labelWidth() {
      return this.isMobile ? undefined : 100;
    },
    labelPosition() {
      return this.isMobile ? "top" : "right";
    },
  },
  created() {
    this.getList();
  },
  mounted() {
  },
  methods: {
    handleView(url) {
      this.imageUrl = url;
      this.$refs.lookImage.open();
    },
    //审核提交
    ok() {
      if (this.formCheckItem.type == 2) {
        if (this.formCheckItem.message == "") {
          this.$Message.error("请填写拒绝原因");
          return;
        }
      }

      storeExtractVerifyApi(this.id, this.formCheckItem)
          .then((res) => {

            this.$Message.success(res.msg);
            this.formCheckItem = {
              type: "1",
              message: "",
            };
            this.checkmodal = false;
            this.getList();
          })
          .catch((err) => {
            this.$Message.error(err.msg);
            this.checkmodal = false;
          });
    },
    // 标签弹窗关闭
    labelClose(e) {
      if (!e) {
        this.getList();
      }
      this.labelShow = false;
      this.labelActive.uid = 0;
    },
    // 提交
    putSend(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          if (!this.formInline.spread_uid) {
            return this.$Message.error("请上传用户");
          }
          agentSpreadApi(this.formInline)
              .then((res) => {
                this.promoterShow = false;
                this.$Message.success(res.msg);
                this.getList();
                this.$refs[name].resetFields();
              })
              .catch((res) => {
                this.$Message.error(res.msg);
              });
        }
      });
    },
    save() {
      this.$modalForm(getUserSaveForm()).then(() => this.getList());
    },
    synchro() {
      userSynchro()
          .then((res) => {
            this.$Message.success(res.msg);
          })
          .catch((err) => {
            this.$Message.error(err.msg);
          });
    },
    // 分组列表
    groupLists() {
      this.loading = true;
      userLabelApi(this.labelFrom)
          .then(async (res) => {
            let data = res.data;
            this.labelLists = data.list;
          })
          .catch((res) => {
            this.loading = false;
            this.$Message.error(res.msg);
          });
    },
    onClickTab(type) {
      this.isAll = 0;
      this.isCheckBox = false;
      this.$refs.xTable.setAllCheckboxRow(false);
      this.checkUidList = [];
      this.userFrom.page = 1;
      this.userFrom.user_type = type==-1?'':type;
      this.getList();
    },
    userGroup() {
      let data = {
        page: 1,
        limit: "",
      };
      userGroupApi(data).then((res) => {
        this.groupList = res.data.list;
      });
    },
    levelLists() {
      let data = {
        page: 1,
        limit: "",
        title: "",
        is_show: 1,
      };
      levelListApi(data).then((res) => {
        this.levelList = res.data.list;
      });
    },
    // 具体日期
    onchangeTime(e) {
      this.timeVal = e;
      this.userFrom.user_time = this.timeVal[0] ? this.timeVal.join("-") : "";
	  this.userSearchs();
    },
    userverify(row){
      this.checkmodal = true
      this.id = row.id
    },
	editUser(row){
		this.editUsermodal = true
		this.id = row.id
	},
    // 操作
    changeMenu(row, name, index) {
      this.userId = row.uid;
      let uid = [];
      uid.push(row.uid);
      let uids = { uids: uid };
      switch (name) {
        case "1":
          this.$refs.userDetails.modals = true;
          this.$refs.userDetails.activeName = "info";
          this.$refs.userDetails.getDetails(row.id);
          break;
        case "2":
          this.getOtherFrom(row.uid);
          break;
        case "3":
          // this.giveLevel(row.uid);
          this.giveLevelTime(row.uid);
          break;
        case "4":
          this.del(
              row,
              "清除 【 " + row.nickname + " 】的会员等级",
              index,
              "user"
          );
          break;
        case "5":
          this.$modalForm(userSetGroup(uids)).then(() =>
              this.$refs.sends.getList()
          );
          break;
        case "6":
          this.openLabel(row);
          // this.$modalForm(userSetLabelApi(uids)).then(() => this.$refs.sends.getList());
          break;
        case "7":
          this.editS(row);
          break;
        default:
          this.del(
              row,
              "解除【 " + row.nickname + " 】的上级推广人",
              index,
              "tuiguang"
          );
          break;
          // this.del(row, '清除 【 ' + row.nickname + ' 】的会员等级', index)
      }
    },
    openLabel(row) {
      this.labelShow = true;
      this.labelActive.uid = row.uid;
    },
    editS(row) {
      this.promoterShow = true;
      this.formInline.uid = row.uid;
    },
    customer() {
      this.customerShow = true;
    },
    imageObject(e) {
      this.customerShow = false;
      if (this.batchModal && this.menuActive === 6) {
        this.batchData.spread_uid = e.uid;
        this.spread_name = e.name;
      } else {
        this.formInline.spread_uid = e.uid;
        this.formInline.image = e.image;
      }
    },
    cancel(name) {
      this.checkmodal = false;
    },
    // 赠送会员等级
    giveLevel(id) {
      giveLevelApi(id)
          .then(async (res) => {
            if (res.data.status === false) {
              return this.$authLapse(res.data);
            }
            this.FromData = res.data;
            this.$refs.edits.modals = true;
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
    // 赠送会员等级
    giveLevelTime(id) {
      giveLevelTimeApi(id)
          .then(async (res) => {
            if (res.data.status === false) {
              return this.$authLapse(res.data);
            }
            this.FromData = res.data;
            this.$refs.edits.modals = true;
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
    // 删除
    del(row, tit, num, name) {
      let delfromData = {
        title: tit,
        num: num,
        url:
            name === "user"
                ? `user/del_level/${row.uid}`
                : `agent/stair/delete_spread/${row.uid}`,
        method: name === "user" ? "DELETE" : "PUT",
        // url: `user/del_level/${row.uid}`,
        // method: 'DELETE',
        ids: "",
      };
      this.$modalSure(delfromData)
          .then((res) => {
            this.$Message.success(res.msg);
            this.getList();
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
    // 清除会员删除成功
    submitModel() {
      this.getList();
    },
    // 会员列表
    getList() {
      this.loading = true;
      this.userFrom.status = this.userFrom.status || "";
      this.userFrom.user_time_type = this.userFrom.user_time_type || "";
      this.userFrom.pay_count = this.userFrom.pay_count || "";
      this.userFrom.field_key = this.field_key === "all" ? "" : this.field_key;
      userList(this.userFrom)
          .then(async (res) => {
            let data = res.data;
            this.userLists = data.list;
            this.total = data.count;
            this.loading = false;
          })
          .catch((res) => {
            this.loading = false;
            this.$Message.error(res.msg);
          });
    },
    pageChange(currentPage) {
      this.userFrom.page = currentPage;
      this.getList();
    },
    // pageChange(index) {
    //   this.userFrom.page = index;
    //   this.getList();
    // },
    // 搜索
    userSearchs() {
      if (this.userFrom.user_time_type && !this.timeVal.length) {
        return this.$Message.error("请选择访问时间");
      }
      if (this.timeVal.length && !this.userFrom.user_time_type) {
        return this.$Message.error("请选择访问情况");
      }
      this.isAll = 0;
      this.$refs.xTable.setAllCheckboxRow(false);
      this.checkUidList = [];
      this.userFrom.page = 1;
      this.selectionList = [];
      this.getList();
    },
    // 重置
    reset(name) {
      this.$refs.xTable.setAllCheckboxRow(false);
      this.checkUidList = []
      this.headeType = "-1";
      this.userFrom = {
        user_type: "",
        status: "",
        sex: "",
        is_promoter: "",
        country: "",
        pay_count: "",
        user_time_type: "",
        user_time: "",
        nickname: "",
        field_key: "",
        level: "",
        group_id: "",
        label_id: "",
        page: 1, // 当前页
        limit: 15, // 每页显示条数
      };
      this.field_key = "";
      this.level = "";
      this.group_id = "";
      this.label_id = "";
      this.user_time_type = "";
      this.pay_count = "";
      this.timeVal = [];
      this.selectionList = [];
      this.dataLabel = [];
      this.getList();
    },
    // 获取编辑表单数据
    getUserFrom(id) {
      this.$modalForm(getUserData(id)).then(() => this.getList());
      // getUserData(id)
      //   .then(async (res) => {
      //     if (res.data.status === false) {
      //       return this.$authLapse(res.data);
      //     }
      //     this.FromData = res.data;
      //     this.$refs.edits.modals = true;
      //   })
      //   .catch((res) => {
      //     this.$Message.error(res.msg);
      //   });
    },
    // 获取积分余额表单
    getOtherFrom(id) {
      editOtherApi(id)
          .then(async (res) => {
            if (res.data.status === false) {
              return this.$authLapse(res.data);
            }
            res.data.rules[1].props.max = 999999;
            this.FromData = res.data;
            this.$refs.edits.modals = true;
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
    // 修改状态
    onchangeIsShow(row) {
      let data = {
        id: row.id,
        status: row.status,
      };
      isShowApi(data)
          .then(async (res) => {
            this.$Message.success(res.msg);
          })
          .catch((res) => {
            this.$Message.error(res.msg);
          });
    },
	onchangeIsStaff(row){
		let data = {
		  id: row.id,
		  staff: row.is_staff,
		};
		isStaffApi(data)
		    .then(async (res) => {
		      this.$Message.success(res.msg);
		    })
		    .catch((res) => {
		      this.$Message.error(res.msg);
		    });
	},
    // 点击发送优惠券
    onSend() {
      if (this.checkUidList.length === 0 && this.isAll==0) {
         return this.$Message.warning("请选择要发送优惠券的用户");
      }
      this.$refs.sends.modals = true;
      this.$refs.sends.getList();
    },
    // 发送图文消息
    onSendPic() {
      if (this.checkUidList.length === 0 && this.isAll==0) {
        this.$Message.warning("请选择要发送图文消息的用户");
      } else {
        this.modal13 = true;
      }
    },
    // 编辑
    edit(row) {
      this.getUserFrom(row.uid);
      // this.$modalForm(getUserSaveForm(row.uid)).then(() => this.getList());
    },
    //信息补充
    extendInfo(row) {
      // this.$modalForm(extendInfo(row.uid)).then(() => this.getList());
      extendInfo(row.uid).then(async (res) => {
        if(res.data.status === false){
          return this.$authLapse(res.data);
        }
        this.FromData = res.data;
        this.$refs.edits.modals = true;
        // this.getList()
      }).catch(err=>{
        this.$Message.error(err.msg);
      })
    },
    // 修改成功
    submitFail(p) {
      // this.getList();
      if (this.$refs.userDetails.modals) {
        this.$refs.userDetails.getDetails(this.userId);
      }
    },
    // 排序
    // sortChanged(e) {
    //   this.userFrom[e.key] = e.order;
    //   this.getList();
    // },
    // onSelectCancel(selection, row) {},
    menuSelect(name) {
      this.menuActive = name;
    },
    setBatch() {
      this.batchModal = true;
    },
    tagClose(id) {
      let index = this.batchLabel.findIndex(item => item.id === id);
      this.batchLabel.splice(index, 1);
    },
    cancelBatch() {
      this.batchModal = false;
    },
    // 保存批量操作
    saveBatch() {
      batchProcess({
        type: this.menuActive,
        uids: this.checkUidList,
        all: this.isAll,
        where: this.userFrom,
        data: this.batchData
      }).then(res => {
        this.$Message.success(res.msg);
        this.batchModal = false;
      }).catch(res => {
        this.$Message.error(res.msg);
      });
    },
    batchVisibleChange() {
      this.batchData = {
        group_id: 0,
        label_id: [],
        level_id: 0,
        money_status: 0,
        money: 0,
        integration_status: 0,
        integration: 0,
        days_status: 1,
        day: 0,
        spread_uid: '',
      };
      this.batchLabel = [];
      this.spread_name = '';
      this.menuActive = 1;
    }
  },
};
</script>

<style scoped lang="stylus">
/deep/.ivu-dropdown-item{
  font-size: 12px!important;
}
/deep/.vxe-table--render-default .vxe-cell{
  font-size: 12px;
}
.expand-row{
  margin-bottom: 16px;
  font-size: 12px;
}
.tdinfo {
  margin-left: 88px;
  margin-top: 15px;
}
.padding-add {
  padding: 20px 20px 0;
}
.input-add {
  max-width:250px;
}
.labelInput {
  max-width:250px;
  border: 1px solid #dcdee2;
  padding: 0 5px;
  border-radius: 5px;
  min-height: 30px;
  cursor: pointer;

  .span {
    color: #c5c8ce;
  }

  .iconxiayi {
    font-size: 12px;
  }
}

.picBox {
  display: inline-block;
  cursor: pointer;

  .upLoad {
    width: 58px;
    height: 58px;
    line-height: 58px;
    border: 1px dotted rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.02);
  }

  .pictrue {
    width: 60px;
    height: 60px;
    border: 1px dotted rgba(0, 0, 0, 0.1);
    margin-right: 10px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.userFrom {
  >>> .ivu-form-item-content {
    margin-left: 0px !important;
  }
}

.userAlert {
  margin-top: 20px;
}

.userI {
  color: #1890FF;
  font-style: normal;
}

img {
  height: 36px;
  display: block;
}

.tabBox_img {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;

  img {
    width: 100%;
    height: 100%;
  }
}

.tabBox_tit {
  width: 60%;
  font-size: 12px !important;
  margin: 0 2px 0 10px;
  letter-spacing: 1px;
  padding: 5px 0;
  box-sizing: border-box;
}

.modelBox {
  >>> .ivu-modal-body {
    padding: 0 16px 16px 16px !important;
  }
}

.vipName {
  color: #dab176;
}

.listbox {
  >>>.ivu-divider-horizontal {
    margin: 0 !important;
  }
}

/deep/.ivu-table-header {
  // overflow visible
}

/deep/.ivu-table th {
  overflow: visible;
}

/deep/.select-item:hover {
  background-color: #f3f3f3;
}

/deep/.select-on {
  display: block;
}

/deep/.select-item.on {
  /* background: #f3f3f3; */
}
.pane_pd{
  padding:4px 16px 20px !important;
  font-weight: 500;
}
.new_tab {
  >>>.ivu-tabs-nav .ivu-tabs-tab{
    padding:4px 16px 20px !important;
    font-weight: 500;
  }
}
.dateMedia{
  /deep/.ivu-form-item-content{
    max-width 250px;
    /deep/.ivu-date-picker{
      width 100%;
    }
  }
}
.select-tag{
  position: relative;
  min-height: 32px;
  padding: 0 24px 0 4px;
  border: 1px solid #dcdee2;
  border-radius: 4px;
  line-height: normal;
  user-select: none;
  cursor: pointer;

  &:hover {
    border-color: #57a3f3;
  }

  .ivu-icon {
    position: absolute;
    top: 50%;
    right: 8px;
    line-height: 1;
    transform: translateY(-50%);
    font-size: 14px;
    color: #808695;
    transition: all .2s ease-in-out;
  }

  .ivu-tag {
    position: relative;
    max-width: 99%;
    height: 24px;
    margin: 3px 4px 3px 0;
    line-height: 22px;
  }

  .placeholder {
    display: block;
    height: 30px;
    line-height: 30px;
    color: #c5c8ce;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 4px;
    padding-right: 22px;
  }
}

>>> .batch-modal {
  .ivu-modal-body {
    padding: 0;
  }

  .ivu-alert {
    margin: 12px 24px;
  }

  .ivu-col-span-4 {
    flex: none;
    width: 130px;
  }

  .ivu-col-span-20 {
    padding-right: 37px;
  }

  .ivu-input-number {
    width: 100%;
  }

  .ivu-menu-light.ivu-menu-vertical .ivu-menu-item-active:not(.ivu-menu-submenu) {
    z-index: auto;
  }

  .ivu-menu-light.ivu-menu-vertical .ivu-menu-item-active:not(.ivu-menu-submenu):after {
    right: auto;
    left: 0;
  }

  .ivu-menu-item {
    padding-right: 0;
  }
}
</style>